<div id="app">
    <child @buttonclick="menuClick" :title="whichnav">{{tt}}插槽会显示这段内容</child>
</div>


<script src="https://unpkg.com/vue/dist/vue.js"></script>

<script>
	// 定义子组件
    Vue.component("child", {
        // 接收父组件传递过来的参数
        props: ["title"],
        
        data() {
            return {
                whichnav: 0
            }
        },
        
        template: "<div><h2>{{title}}</h2><slot></slot><p>{{count}}</p><button @click='handleClick' data-w='1'>按钮</button><button @click='handleClick' data-w='2'>按钮</button></div>",
        
        methods: {
            handleClick() {
                // 向父组件传递事件
                this.$emit("buttonclick", this.whichnav = event.currentTarget.dataset.w);
            }
        }
    });
	
	// 实例化Vue对象
    var vm = new Vue({
        el: "#app",
        
        data() {
            return {
                whichnav: "kk"
            }
        },
        
        methods: {
            // 接收子组件传递回来的参数
            menuClick(whichnav) {
                this.whichnav = whichnav
            }
        }
    })
</script>